package com.simple.javatraining.testing.QuestionsFactory;

import com.simple.javatraining.testing.testinside.answers.ProposedAnswer;
import com.simple.javatraining.testing.testinside.questions.*;

import java.util.List;

public class QuestionFactory {
    public static Question createQuestion(String type,
                                          String textOfQuestion,
                                          List<ProposedAnswer> variantsOfAnswer,
                                          double delta) {
        if (type.equals("QuestionWithSingleAnswer")) {
            return new QuestionWithSingleAnswer(textOfQuestion, variantsOfAnswer);
        } else if (type.equals("QuestionWithYesNoAnswer")) {
            return new QuestionWithYesNoAnswer(textOfQuestion, variantsOfAnswer);
        } else if (type.equals("QuestionWithSeveralAnswers")) {
            return new QuestionWithSeveralAnswers(textOfQuestion, variantsOfAnswer);
        } else if (type.equals("QuestionWithEnterableAnswer")) {
            return new QuestionWithEnterableAnswer(textOfQuestion, variantsOfAnswer);
        } else if (type.equals("QuestionWithAnswerWithinRange")) {
            return new QuestionWithAnswerWithinRange(textOfQuestion, variantsOfAnswer, delta);
        } else {
            throw new IllegalArgumentException("Unknown question type!");
        }
    }
}
